package com.huyna.docbao;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class CategoryFragment extends Fragment{

    /* Array image resource */
    public final Integer[] mImageId={
            R.drawable.gallery_photo_1,
            R.drawable.gallery_photo_2,
            R.drawable.gallery_photo_3,
            R.drawable.gallery_photo_4,
            R.drawable.gallery_photo_5,
            R.drawable.gallery_photo_6,
            R.drawable.gallery_photo_7,
            R.drawable.gallery_photo_8
        };
    
    private ImageView imageView;
    private int position = 0;
    
    /*
     * Constructor CategoryFragment
     */
    public static CategoryFragment newInstance(int pos){
        CategoryFragment category = new CategoryFragment();
        Bundle args = new Bundle();
        args.putInt("position", pos);
        category.setArguments(args);
        return category;
    }
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(getArguments() != null){
            position = getArguments().getInt("position");
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_category, null);
        imageView = (ImageView)v.findViewById(R.id.imageFragment);
        imageView.setImageResource(mImageId[position]);
        return v;
    }
}
